<template>
  <!--  <van-grid>-->
  <!--    <van-grid-item icon="photo-o" text="沪深京A股" />-->
  <!--  </van-grid>-->
</template>

<script>
import {Dialog} from "vant";

export default {
  data() {
    return {
      userInfo: {
        sequence: null,
        created_at: 0
      }
    }
  },
  methods: {
    loadUserInfo() {
      this.$requests.post('/user/info/obtain').then(resp => {
        let timeNow = new Date()
        timeNow = timeNow.getTime()
        timeNow = timeNow / 1000
        this.userInfo = resp
        if (
          !Object.assign.hasOwnProperty.call(this.userInfo, 'sequence') &&
          (timeNow - this.userInfo.created_at) > 7 * 24 * 60 * 60
        ) {
          Dialog.confirm({
            title: '提示',
            message: '你尚未完成实名认证，认证后可免费获得30天全量数据权益',
            confirmButtonText: '去认证'
          }).then(() => {
            this.$router.push('/verify')
          }).catch(() => {
            this.$router.push('/trend/stock')
          })
        } else {
          this.$router.push('/trend/stock')
        }
      })
    }
  },
  mounted() {
    this.loadUserInfo()
  }
}
</script>
